package main

import (
	"fmt"
	"reflect"
)

type Student struct {
	name string `json:"name"`
	age int `json:"age"`
	sex string
}

// 结构体方法
func (s Student) Print()  {
	fmt.Println("======================", s.name, "==========================")

}

func (s Student) Add(name string) {
	s.name = name
}

func reflectStruct(b interface{})  {
	rtype := reflect.TypeOf(b)
	fmt.Println(rtype.NumMethod())
	rtype.Method(1)
	//reflect.StructField{Tag: }
	field := rtype.Field(0)
	fmt.Println(field.Tag.Get("age"))

}

func main() {
	// 创造一个结构体。
	student := Student{
		name: "xyt",
		age:  12,
		sex:  "男",
	}

	reflectStruct(student)
}
